package com.kele.controller;

import com.kele.domain.Follow;
import com.kele.domain.User;
import com.kele.service.FollowService;
import com.kele.service.UserService;
import com.kele.utils.ResponseData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class JudgeFollowController {
    @Resource
    FollowService followService;
    @Resource
    UserService   userService;
    @RequestMapping(value = "judgeFollow",method = RequestMethod.GET)
    @ResponseBody
    public ResponseData judgeFollow(int userid, int bloggerid){
        Follow follow=followService.findFollow(userid, bloggerid);
        User user=userService.queryUserById(bloggerid);
        System.out.println(follow);
        System.out.println(user.getFans());
        if(follow!=null){
            return ResponseData.success("1",user.getFans());

        }else {
            return  ResponseData.success("0",user.getFans());
        }

    }
}
